package nl.ceasaro.poker.ranking;

import nl.ceasaro.playingcards.Card;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: cees
 * Date: May 14, 2007
 * Time: 9:12:56 PM
 * <p/>
 * The highest possible combination of five cards a player has in is hand.
 */
public class PokerHand
{
   private List<Card> combinationCards;
   private PokerRanker.PokerRank rank = PokerRanker.PokerRank.NONE;
   private Card kicker;
   private Card secondKicker;
   private Card thirdKicker;

   public PokerHand(List<Card> combi, PokerRanker.PokerRank rank)
   {
      Collections.sort(combi);
      this.combinationCards = combi;
      this.rank = rank;
   }

   public List<Card> getHand()
   {
      ArrayList<Card> hand = new ArrayList<Card>();
      if (getCombinationCards() != null)
      {
         hand.addAll(getCombinationCards());
      }
      if (getKicker() != null)
      {
         hand.add(getKicker());
      }
      if (getSecondKicker() != null)
      {
         hand.add(getSecondKicker());
      }
      if (getThirdKicker() != null)
      {
         hand.add(getThirdKicker());
      }
      return hand;
   }

   public List<Card> getCombinationCards()
   {
      return combinationCards;
   }

   public void setCombinationCards(List<Card> combinationCards)
   {
      this.combinationCards = combinationCards;
   }

   public PokerRanker.PokerRank getRank()
   {
      return rank;
   }

   public void setRank(PokerRanker.PokerRank rank)
   {
      this.rank = rank;
   }

   public Card getKicker()
   {
      return kicker;
   }

   public void setKicker(Card kicker)
   {
      this.kicker = kicker;
   }

   public Card getSecondKicker()
   {
      return secondKicker;
   }

   public void setSecondKicker(Card secondKicker)
   {
      this.secondKicker = secondKicker;
   }

   public Card getThirdKicker()
   {
      return thirdKicker;
   }

   public void setThirdKicker(Card thirdKicker)
   {
      this.thirdKicker = thirdKicker;
   }

   public void clearKickers()
   {
      setKicker(null);
      setSecondKicker(null);
      setThirdKicker(null);
   }
}
